<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>批量提交122</title>
    <link href="../../layui/css/layui.css" rel="stylesheet">
    <link href="../../static/css/style.css" rel="stylesheet">
    <script src="../../static/js/jquery.min.js"></script>
    <script src="../../static/js/jquery.cookie.js"></script>
    <script src="../../layui/layui.js"></script>
    <script src="../../static/js/base.js"></script>
    <script src="../../static/js/ax.js"></script>
    <script src="../../static/js/avalon.js"></script>
    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
    <!--[if lt IE 9]>
    <script src="../../static/js/html5.js"></script>
    <script src="../../static/js/respond.js"></script>
    <![endif]-->

</head>

<body class="bg_w">

    <div class="xyxx">
        <div class="layui-card-body" ms-controller="submit122">
            <form class="layui-form layui-form-pane" action="" lay-filter="component-form-element">
                <div class="layui-row layui-col-space10 layui-form-item">
                    <div class="layui-inline layui-col-lg3 layui-col-sm6">
                        <label class="layui-form-label">姓名或证件号码</label>
                        <div class="layui-input-block">
                            <input type="text" name="name" :duplex="nameOrNum" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-inline layui-col-lg3 layui-col-sm6">
                        <label class="layui-form-label">报名机构</label>
                        <div class="layui-input-block">
                            <select id="branchSchoolId" name="branchSchoolId" lay-filter="branchSchoo">

                                <option value="">请选择</option>
                                <option ms-attr="{value: el.id}" ms-for="($index, el) in @shoollis">{{el.name}}</option>

                            </select>
                        </div>
                    </div>
                    <div class="layui-inline  layui-col-lg3 layui-col-sm6">
                        <label class="layui-form-label">报名日期</label>
                        <div class="layui-input-block">
                            <input type="text" name="enrolltime" id="enrolltime" class="layui-input" placeholder="yyyy-MM-dd">
                        </div>
                    </div>
                    <div class="layui-col-lg3 layui-col-sm6">
                        <a type="reset" class="layui-btn add_btn" :click="shearch()">查询</a>
                        <a class="layui-btn add_btn" :click="checkAll()">全选</a>
                        <a class="layui-btn delete_btn" :click="checkAllno()">取消全选</a>
                    </div>

                </div>



                <div class="layui-form-item layui-form-text">
                    <label class="layui-form-label">待提交、已提交至总校的学员共计：{{StudentNum}}人</label>
                    <div class="layui-input-block">
                        <table class="layui-hide" id="Tbale" lay-filter="active"></table>
                    </div>
                </div>
                <!--模板-->

                <div class="layui-form-item layui-col-space10">
                    <!--<table class="layui-hide" id="Tbale2" lay-filter="eventBtn"></table>-->


                    <div class="layui-input-block">
                        <a id="btnClose" class="layui-btn layui-btn-primary btn-left">关闭</a>
                        <a class="layui-btn add_btn btn-left"  :click="updateState()" >提交</a>

                    </div>
                </div>
            </form>
        </div>
    </div>


</body>

<script>
    var table;
    var form;
    var vm = avalon.define({
        $id: "submit122",
        nameOrNum: "",
        driversId: "",
        timeStart: "",
        timeEdd: "",
        StudentNum: "",
        shoollis: [],
        shearch: function () {
            table.reload('submitTbale', {
                page: {
                    curr: 1 //重新从第 1 页开始
                }
                , where: {
                    nameOrNum: vm.nameOrNum,
                    driversName: vm.driversId,
                    timeStart: vm.timeStart,
                    timeEdd: vm.timeEdd,
                }
            });
            console.log(vm.nameOrNum)
        },
        getStateStudentNum: function () {
            ax.get({
                type: "get",
                url: schoolWebUrl + "/api/student/getStateStudentNum",
                async: false,  //加了这个属性，
                contentType: "application/x-www-form-urlencoded",
                error: function (request) {

                },
                success: function (data) {
                    if (data.code == 0) {
                        console.log(data)
                        vm.StudentNum = data.data

                    } else {
                    }

                }
            });
        },
        // 全选
        checkAll: function () {
            var checkStatus = table.checkStatus('submitTbale');
            if (checkStatus.isAll == true) {
                return;
            }
            $('.layui-form-checkbox').click();
            form.render('checkbox');
            console.log(checkStatus)
        },
        // 反选
        checkAllno: function () {
            var checkStatus = table.checkStatus('submitTbale');
            if (checkStatus.isAll == false) {
                return;
            }
            $('.layui-form-checkbox').click();
            form.render('checkbox');
        },
        // 获取机构列表
        getshoollist: function () {
            ax.get({
                type: "get",
                url: schoolWebUrl + "/api/gather/getSchoolTree",
                async: false,  //加了这个属性，
                contentType: "application/x-www-form-urlencoded",
                error: function (request) {

                },
                success: function (data) {
                    if (data.code == 0) {
                        console.log(data)
                        vm.shoollis = data.data;
                    } else {
                    }

                }
            });
        },
        updateState:function(){
            var checkStatus = table.checkStatus('submitTbale');
             var data=checkStatus.data;
             var datas=[]
             for(var i in data){
                datas.push(data[i].id)
             }
            
            ax.get({
                url: schoolWebUrl + "/api/student/updateState122State",
                async: false,  //加了这个属性，
                data:{ ids: datas },
                error: function (request) {

                },
                success: function (data) {
                    layer.msg(data.msg)
                    if (data.code == 0) {
                        console.log(data)
                        parent.location.reload();
                        layer.closeAll("iframe");
                    } else {
                        layer.msg(data.msg)
                    }

                }
            }); 
            return false;  
        }

    });
    vm.$watch('onReady', function () {
        //获取省市区
        console.log(1)
        vm.getStateStudentNum();
        vm.getshoollist();


    })





    layui.use(['table', 'form', 'laydate', 'layer', 'upload'], function () {
        table = layui.table;
        form = layui.form;
        var laydate = layui.laydate,
            layer = layui.layer,
            $ = layui.jquery,
            upload = layui.upload;

        //常规用法
        laydate.render({
            elem: '#enrolltime'
            , range: true,
            done: function (value, date, date2) {
                vm.timeStart = date.year + '-' + date.month + '-' + date.date;
                vm.timeEdd = date2.year + '-' + date2.month + '-' + date2.date;

                console.log(vm.timeStart)
                console.log(vm.timeEdd)

            }
        });

        var tableIns = ax.VTable({
            elem: '#Tbale',
            url: schoolWebUrl + '/api/student/sumbit122',
            id: 'submitTbale',
            title: '已提交、待提交总校学员列表',
            cols: [[
                { type: 'checkbox', fixed: 'left' },
                { type: "numbers", width: 80, title: '序号', sort: true },
                { field: 'registeredSource', minWidth: 150, title: '报名机构', sort: true },
                { field: 'name', minWidth: 100, title: '姓名', },
                { field: 'certificatesNumber', minWidth: 180, title: '证件号码' },
                { field: 'carName', width: 150, title: '准驾车型' },
                { field: 'phone', width: 180, title: '联系电话' },
            ]]

        });

        //机构改变
        form.on('select(branchSchoo)', function (data) {
            console.log(data)
            vm.driversId = data.value;
            console.log(data.value);
        });

        //关闭弹窗
        $('#btnClose').on("click", function () {
            parent.layer.close(parent.layer.getFrameIndex(window.name));
        });

        //监听提交

        form.on('submit(component-form-element)', function (data) {

        });

    });


</script>

</html>